﻿
using System;

namespace GameControls
{
    public class ActiveObject
    {
        public delegate void SelectedHandler(object obj);
        private event SelectedHandler _SelectedEvent;
        public event SelectedHandler SelectedEvent
        {
            add { _SelectedEvent += value; }
            remove { _SelectedEvent -= value; }
        }
        
        private object _SelectedObject;
        
        public ActiveObject() { }
        
        public object SelectedObject
        {
            get { return _SelectedObject; }
            set 
            { 
                if (_SelectedObject != value)
                {
                    _SelectedObject = value; 
                    if (_SelectedEvent != null)
                    {
                        _SelectedEvent(value);
                    }
                }
            }
        }
        
    }
}
